$(function(){
	var path = window.location.href;
	var orderId = path.substring(path.indexOf("=") + 1);
	var token=localStorage.getItem("key");
	console.log(token);
	$.ajax({
		type:"post",
		url:"/api/me/getMyOrderDetail",
		async:true,
		data:JSON.stringify({"data":{"orderId":orderId,"token":token}}),
		dataType:"json",
		success:function(data){
			var list=data.data.goods;
			console.log(list);
			for(var i=0;i<list.length;i++){
				$('.name span').html(list[i].goodsName);
				$('.price span').html('￥'+Number(list[i].goodsPrice+Number(data.data.postage)));
			}
		}
	});
	
	
	$('.pay').on("click",function(){
		payType = ($(this).data('set'));
		console.log(payType);
	});
	
	
	$('.ensurePay').on("click",function(){
		$.ajax({
			type:"get",
			url:"/api/me/payOrder",
			async:true,
			data:{"orderId":orderId,"payType":payType,"token":token},
			dataType:"json",
			success:function(data){
				console.log(data);
				window.location.href="success.html";
			}
		});
	})
});
